
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.job.dto.TrainingVideoDTO;
import com.insigma.business.qrcode.job.dto.request.TrainingVideoInsertRequest;
import com.insigma.business.qrcode.job.dto.request.TrainingVideoSearchRequest;
import com.insigma.business.qrcode.job.dto.request.TrainingVideoUpdateRequest;
import com.insigma.business.qrcode.job.dto.search.TrainingVideoBSearcher;
import com.insigma.business.qrcode.job.entity.TrainingVideoDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class TrainingVideoProviderConverter extends AbstractConverter<TrainingVideoDTO, TrainingVideoDO> {

    private final static TrainingVideoProviderConverter trainingVideoConverter = new TrainingVideoProviderConverter();

    private TrainingVideoProviderConverter(){}

    
    public static TrainingVideoBSearcher convertRequestSO2Searcher(final TrainingVideoSearchRequest request){
        final TrainingVideoBSearcher trainingVideoBSearcher = new TrainingVideoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,trainingVideoBSearcher);
        return trainingVideoBSearcher;
    }

    
    public static TrainingVideoDO convertRequestUO2DO(final TrainingVideoUpdateRequest trainingVideoUpdateRequest) {
        final TrainingVideoDO trainingVideoDO = new TrainingVideoDO();
        BeanUtils.copyProperties(trainingVideoUpdateRequest,trainingVideoDO);
        
        return trainingVideoDO;
    }

    
    public static TrainingVideoDO convertRequestIO2DO(final TrainingVideoInsertRequest trainingVideoInsertRequest) {
        final TrainingVideoDO trainingVideoDO = new TrainingVideoDO();
        BeanUtils.copyProperties(trainingVideoInsertRequest,trainingVideoDO);
        return trainingVideoDO;
    }

    
    public static List<TrainingVideoDTO> convertResponseDOList2DTOList(final List<TrainingVideoDO> trainingVideoDOList){
        return trainingVideoConverter.convertGenericResponseDOList2DTOList(trainingVideoDOList);
    }

    
    public static TrainingVideoDTO convertResponseDO2DTO(final TrainingVideoDO trainingVideoDO){
        return trainingVideoConverter.convertGenericResponseDO2DTO(trainingVideoDO);
    }

    
    @Override
    protected TrainingVideoDTO doConvertResponseDO2DTO(TrainingVideoDO trainingVideoDO) {
        final TrainingVideoDTO trainingVideoDTO = new TrainingVideoDTO();
        try {
            BeanUtils.copyProperties(trainingVideoDO, trainingVideoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return trainingVideoDTO;
    }

}
